﻿<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<html>
<head>
    <title>Namaz Vakitleri</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
        html, body
        {
            margin: 0;
            padding: 0;
            height: 100%;
            font-family: Verdana;
            color: Navy;
        }
        #map_canvas
        {
            margin: 0;
            padding: 0;
            height: 100%;
        }
        .Zaman
        {
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;
            position: absolute;
            top: 35;
            left: 5;
            background-color: White;
            opacity: .80;
            -moz-opacity: .80;
            filter: alpha(opacity=80);
            margin-top: 10px;
            margin-bottom: 10px;
            margin-right: 10px;
            margin-left: 10px;
        }
        table
        {
            border: none;
            border-collapse: collapse;
        }
        
        td
        {
            border-bottom: 1px dotted;
            margin: 0;
            padding: 1px;
        }
        
        tr
        {
            margin: 0;
            padding: 0;
        }
        .styled-button-3
        {
            -webkit-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0;
            -moz-box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0;
            box-shadow: rgba(0,0,0,0.0.1) 0 1px 0 0;
            background-color: #5B74A8;
            border: 1px solid #29447E;
            font-family: 'Lucida Grande' ,Tahoma,Verdana,Arial,sans-serif;
            font-size: 12px;
            font-weight: 700;
            padding: 2px 6px;
            height: 28px;
            color: #fff;
            border-radius: 5px;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            -khtml-border-radius: 5px;
            cursor: pointer;
        }
    </style>
    <script type="text/javascript" language="javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" language="javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true&libraries=places"></script>
    <script type="text/javascript" language="javascript">
        var map;
        var yer;
        var http;
        var elevator;
        var service;
        var now = new Date();
        var tarih = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate();
        var lat = 41.015895;
        var lng = 28.963978;
        var alt = 62;
        var utc = now.getTimezoneOffset() / 60;
        var daylight = 0;
        var routeMarkers = new Array(0);
        var myDate = new Date();
        var request;
        var yeniYer = "H";

        google.maps.event.addDomListener(window, 'load', initialize);

        function initialize() {
            checkTimeZone();

            http = createRequestObject();

            yer = new google.maps.LatLng(lat, lng);

            var mapOptions = {
                zoom: 12,
                center: yer,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);

            var marker = placeMarker(yer, "");
            routeMarkers.push(marker);

            elevator = new google.maps.ElevationService();
            google.maps.event.addListener(map, 'click', getElevation);

            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(handle_geolocation_query, onError);
            }
            else {
                getVakit(lat, lng, alt);
            }
        }



        function processResponse() {
            if (http.readyState == 4) {
                var response = http.responseText;
                document.getElementById("zaman").innerHTML = response;
            }
        }
        function getElevation(event) {
            yeniYer = "E";
            var locations = [];
            var clickedLocation = event.latLng;
            locations.push(clickedLocation);
            var positionalRequest = { 'locations': locations };
            elevator.getElevationForLocations(positionalRequest, function (results, status) {
                lat = event.latLng.lat().toFixed(6);
                lng = event.latLng.lng().toFixed(6);
                alt = 0;
                if (status == google.maps.ElevationStatus.OK) {
                    if (results[0]) {
                        removeOldMarker();
                        alt = results[0].elevation.toFixed(6);
                        var marker = placeMarker(clickedLocation, results[0].elevation.toFixed(2) + " m");
                        marker.setMap(map);
                        routeMarkers.push(marker);
                        getVakit(lat, lng, alt);
                    }
                }
            });
        }
    </script>
    <script type="text/javascript" language="javascript">
        function checkTimeZone() {
            var rightNow = new Date();
            var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
            var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
            var temp = date1.toGMTString();
            var date3 = new Date(temp.substring(0, temp.lastIndexOf(" ")));
            temp = date2.toGMTString();
            var date4 = new Date(temp.substring(0, temp.lastIndexOf(" ")));
            var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
            var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
            utc = hoursDiffStdTime;
            if (hoursDiffDaylightTime == hoursDiffStdTime) {
                daylight = 0;
            } else {
                daylight = 1;
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        function getVakit(lat, lng, alt) {
            document.getElementById("zaman").innerHTML = "<img src='image/bekle.gif' alt='Bekle' style='width:100px' />";

            http.open('get', 'Hesap.aspx?lat=' + escape(lat) + '&long=' + escape(lng) + '&alt=' + escape(alt) + "&trh=" + tarih + "&utc=" + utc + "&dls=" + daylight + "&yeniyer=" + yeniYer);
            http.onreadystatechange = processResponse;
            http.send(null);
        }

        function goster(tip) {
            for (i = 1; i < 6; i++) {
                document.getElementById('tbl' + i).style.display = "none";
            }
            document.getElementById('tbl' + tip).style.display = "block";
        }
    </script>
    <script type="text/javascript" language="javascript">
        function handle_geolocation_query(position) {
            lat = position.coords.latitude;
            lng = position.coords.longitude;
            yer = new google.maps.LatLng(lat, lng);

            map.setCenter(yer, 13);
            map.panTo(yer);

            var locations = [];
            var clickedLocation = yer;
            locations.push(clickedLocation);
            var positionalRequest = { 'locations': locations };
            elevator.getElevationForLocations(positionalRequest, function (results, status) {
                alt = 0;
                if (status == google.maps.ElevationStatus.OK) {
                    if (results[0]) {

                        removeOldMarker();
                        alt = results[0].elevation.toFixed(6);
                        var marker = placeMarker(clickedLocation, results[0].elevation.toFixed(2) + " m");
                        marker.setMap(map);
                        routeMarkers.push(marker);
                        getVakit(lat, lng, alt);
                    }
                }
            });
        }

        function onError(error) {
            alert("Lokasyon bilgisine erişilemedi. Lütfen ayarlarınızı kontrol ediniz \n Sistemsel Kod: " + error.code + "\n mesaj :" + error.message + "\n");
            getVakit(lat, lng, alt);
        }
    </script>
    <script type="text/javascript" language="javascript">
        function createRequestObject() {
            var tmpXmlHttpObject;
            if (window.XMLHttpRequest) {
                tmpXmlHttpObject = new XMLHttpRequest();

            } else if (window.ActiveXObject) {
                tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
            }
            return tmpXmlHttpObject;
        }
    </script>
    <script type="text/javascript" language="javascript">
        function removeOldMarker() {
            for (var i = 0; i < routeMarkers.length; i++) {
                routeMarkers[i].setMap(null);
            }
            routeMarkers = new Array(0);
        }
        function placeMarker(location, text) {
            var image = new google.maps.MarkerImage('stripes.png',
            new google.maps.Size(20, 34),
            new google.maps.Point(0, 0),
            new google.maps.Point(9, 33));
            var shadow = new google.maps.MarkerImage('shadow.png',
            new google.maps.Size(28, 22),
            new google.maps.Point(0, 0),
            new google.maps.Point(1, 22));
            var marker = new google.maps.Marker({ position: location, map: map, shadow: shadow, icon: image, title: text });
            return marker;
        }
    </script>
    <script type="text/javascript" language="javascript">
    </script>
    <script type="text/javascript" language="javascript">
    </script>
</head>
<body>
    <form id="Form1" runat="server">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
        <tr>
            <td style="height: 30px">
                <button class="styled-button-3" onclick='goster(1);return false;' runat="server"
                    id="btnVakit">
                    V</button>&nbsp;
                <button class="styled-button-3" onclick='goster(2);return false;' runat="server"
                    id="btnTeknik">
                    T</button>&nbsp;
                <button class="styled-button-3" onclick='goster(3);return false;' runat="server"
                    id="btnAy">
                    A</button>&nbsp;
                <button class="styled-button-3" onclick='goster(4);return false;' runat="server"
                    id="btnBirAylik">
                    A</button>&nbsp;
                <button class="styled-button-3" onclick='goster(5);return false;;' runat="server"
                    id="btnProgram">
                    A</button>
            </td>
        </tr>
        <tr>
            <td style="height: auto">
                <div id="map_canvas" />
            </td>
        </tr>
    </table>
    <div id="zaman" class="zaman" />
    </form>
</body>
</html>
